package com.imooc.distributelock.lock;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.Condition;

public abstract  class AbstractLock implements Lock {
    protected String lockName;

    @Override
    public void lock() {

    }
    //创建的抽象方法，子类一定要实现该方法吗？是的，否则子类也必须为抽象类
    //根据获取的参数进行锁的获取
    public abstract void lock(TimeUnit timeUnit, Long expireTime);

    @Override
    public void lockInterruptibly() throws InterruptedException {

    }

    @Override
    public boolean tryLock(long time, TimeUnit unit) throws InterruptedException {
        return false;
    }
    //根据获取的参数进行尝试获取锁
    public abstract boolean tryLock(long time, long expireTime, TimeUnit unit) throws InterruptedException;

    @Override
    public void unlock() {

    }

    @Override
    public Condition newCondition() {
        return null;
    }
}
